# https://segmentfault.com/a/1190000008699980
def search(nums, k):
    left = 0
    right = len(nums) - 1

    while left <= right:

        mid = (left + right) / 2

        if nums[mid]>k:
            right = mid -1
        elif nums[mid]<k:
            left = mid + 1
        else:
            return mid

    return -1

nums=[1,3,5,8,11,34,56,101,201,988]
ret = search(nums, 1)
print(ret, " len=", len(nums))